import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class CoreMemberLabelService extends BaseService<any> {
  private readonly logger = new Logger(CoreMemberLabelService.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * getMemberLabelListByLabelIds
   * 对应 PHP: CoreMemberLabelService_core::getMemberLabelListByLabelIds()
   * 逻辑类型: undefined - undefined
   */
  async getMemberLabelListByLabelIds(site_id: any[], label_ids: any[]) {
    // 基于PHP真实逻辑: getMemberLabelListByLabelIds
    // PHP原文: sort($label_ids);         $cache_name = __METHOD__ . md5(implode("_", $label_ids));         return cache_remember(             $cache_name,           ...
sort(label_ids);
        const cache_name = __METHOD__ . md5(implode("_", label_ids)];
        return cache_remember(
            cache_name,
            function() use (site_id, label_ids) {
                return array_keys_search(this.getAll(site_id), label_ids, 'label_id'];
  }

  /**
   * getAll
   * 对应 PHP: CoreMemberLabelService_core::getAll()
   * 逻辑类型: undefined - undefined
   */
  async getAll(site_id: number) {
    // 基于PHP真实逻辑: getAll
    // PHP原文: $cache_name = __METHOD__ . $site_id;         return cache_remember(             $cache_name,             function() use ($site_id) {                 $...
const cache_name = __METHOD__ . site_id;
        return cache_remember(
            cache_name,
            function() use (site_id) {
                const field = 'label_id, label_name';
                return this.model.where([ [ 'site_id', '=', site_id ) )).field(field).order('sort desc,create_time desc').select().toArray(];
  }

  /**
   * clearCache
   * 对应 PHP: CoreMemberLabelService_core::clearCache()
   * 逻辑类型: undefined - undefined
   */
  async clearCache(site_id: number) {
    // 基于PHP真实逻辑: clearCache
    // PHP原文: Cache::tag(self::$cache_tag_name . $site_id)->clear();         return true;     } }...
Cache.tag(self.cache_tag_name . site_id).clear(];
        return true;
    }
}
  }
}
